

<!-- Right side column. Contains the navbar and content of the page -->
<aside class="right-side">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>Add User </h1>
    </section>
    <!-- Main content -->
    <section class="content">
        <div class="row">
            <!-- left column -->
            <div class="col-md-12">
                <!-- general form elements -->
                <div class="box box-primary">
                    <?php $msg = $this->session->flashdata('msg');
                    if ($msg!= '') {
                        ?>
                        <div class="alert alert-warning alert-dismissable">
                            <i class="fa fa-warning"></i>
                            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                            <b>Alert!</b> <?php echo $msg; ?>
                        </div>
                      <?php  }
                        ?>
                        <!-- form start -->
                        <form role="form" method="POST" action="" name="editregistration">
                            <div class="box-body"><?php foreach ($user as $data) { ?>
                                    <input type="hidden" name="id" value="<?php echo $data->id; ?>" class="form-control">
                                    
                                    <div class="form-group">
                                        <label for="username">Username</label>
                                        <input type="text" class="form-control" id="username" placeholder="username" name="username" value="<?php echo $data->username; ?>" onblur="user_check(this.value);
                                                " disabled><div id="Msg"></div>
        <?php echo form_error('username'); ?>
                                    </div>
                                    <div class="form-group">
                                        <label for="name">Name</label>
                                        <input type="text" class="form-control" id="name" placeholder="Enter Name" name="name" value="<?php echo $data->name; ?>">
        <?php echo form_error('name'); ?>
                                    </div>
                                    <div class="form-group">
                                        <label for="name">Gender</label>
                                        <input type="text" class="form-control" id="name" placeholder="Enter Name" name="name" value="<?php echo $data->name; ?>">
        <?php echo form_error('name'); ?>
                                    </div>
                                    <div class="form-group">
                                        <label for="email">Email address</label>
                                        <input type="email" class="form-control" id="email" placeholder="Enter email" name="email" value="<?php echo $data->email; ?>">
        <?php echo form_error('email'); ?>
                                    </div>
                                    <div class="form-group">
                                        <label for="password">Password</label>
                                        <input type="password" class="form-control" id="password" placeholder="Password" name="password" value="<?php echo $data->password; ?>">
                                    <?php echo form_error('password'); ?>
                                    </div>
    <?php } ?>
                            </div><!-- /.box-body -->

                            <div class="box-footer">
                                <button type="submit" class="btn btn-primary" name="submit">updateUser</button>
                            </div>
                        </form>
                    </div><!-- /.box -->
                    <script>
                        function user_check(val)
                        {
                            if (val != '')
                            {

                                var str = 'user=' + val;
                                $.ajax({
                                    type: "POST",
                                    url: "<?php echo base_url(); ?>user/check_User",
                                data: str,
                                success: function(data)
                                {
                                    //alert(data);
                                    if (data == 0)
                                    {
                                        $("div#Msg").html("<span class='succ'>User Name Available.</span>");
                                    }
                                    else
                                    {
                                        document.getElementsByName("username").value = '';
                                        $("div#Msg").html("<span class='err'>User Name already exist.</span>");
                                    }
                                }
                            });
                        }

                    }

                </script>

